<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateGoodsWatchLogsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('goods_watch_logs', function (Blueprint $table) {
            $table->id();
            $table->timestamps();
            $table->ipAddress("ip_addr")->index()->comment("用户的ip");
            $table->foreignId("goods_id")
                ->references("id")->on("goods")
                ->comment("商品")->onDelete("cascade");
            $table->bigInteger("user_id")->comment("用户id")->nullable();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('goods_watch_logs');
    }
}
